package com.hd.tiyu.yuejian.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.hd.tiyu.yuejian.JavaBean.Actcate;
import com.hd.tiyu.yuejian.Model.ListsModel;
import com.hd.tiyu.yuejian.R;
import com.squareup.picasso.Picasso;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by Administrator on 2017/9/30.
 */
//活动详情
public class ActacteActivity extends AppCompatActivity {
    private TextView activity_name,start_date,province_name,city_name,district_name,update_time;
    private TextView activity_price,attend_num,contact_tel,introduction,top_name;
    private ImageView img;
    private Button btn;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.avtivity_actcate);
        initView();
        initEvent();
        initData();
    }
    private void initView() {

        img=(ImageView)findViewById(R.id.actcate_imageView);
        top_name= (TextView) findViewById(R.id.top_name);
        activity_name=(TextView)findViewById(R.id.actcate_activity_name);
        start_date= (TextView) findViewById(R.id.actcate_start_date);
        province_name= (TextView) findViewById(R.id.province_name);
        city_name= (TextView) findViewById(R.id.city_name);
        district_name= (TextView) findViewById(R.id.district_name);
        update_time= (TextView) findViewById(R.id.actcate_update_time);
        activity_price= (TextView) findViewById(R.id.actcate_activity_price);
        attend_num= (TextView) findViewById(R.id.actcate_attend_num);
        contact_tel= (TextView) findViewById(R.id.actcate_contact_tel);
        introduction= (TextView) findViewById(R.id.actcate_introduction);
        btn=(Button)findViewById(R.id.actcate_baoming);
    }
    private void initData() {
        Intent intent=getIntent();
        String id=intent.getStringExtra("id");
        ListsModel model=new ListsModel();
        Call<Actcate>call=model.getActivity(id);
        call.enqueue(new Callback<Actcate>() {
            @Override
            public void onResponse(Call<Actcate> call, Response<Actcate> response) {
                Actcate data=response.body();
                activity_name.setText(data.getActivity_name());
                top_name.setText(data.getActivity_name());
                Picasso.with(ActacteActivity.this).load("http://172.24.10.175/workout/Uploads/"+data.getThumb()).resize(300,150).centerCrop().into(img);
                start_date.setText(data.getStart_date());
                province_name.setText(data.getProvince_name());
                city_name.setText(data.getCity_name());
                district_name.setText(data.getDistrict_name());
                update_time.setText(data.getUpdate_time());
                activity_price.setText(data.getActivity_price());
                attend_num.setText(data.getAttend_num());
                contact_tel.setText(data.getContact_tel());
                introduction.setText(data.getIntroduction());
            }

            @Override
            public void onFailure(Call<Actcate> call, Throwable t) {

            }
        });

    }

    private void initEvent() {
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });
    }



}
